export default {
  name: "companyDetail",
  props: ["companyName", "tabNum", "companyId", "type"],
  data() {
    return {
      dialogVisible: false,
      result: "1",
      remark: "",
      baseInfo: {},
      statusList: {
        "0": "待审核",
        "1": "已通过",
        "2": "未通过"
      },
      logoUrl: "",
      imgDatas: [],
      imgDialogVisible: false,
      yzImg: [],
    };
  },
  mounted() {
    this.basicInfor();
  },
  watch: {
    companyId() {
      this.basicInfor();
    }
  },
  methods: {
    // 基本信息
    basicInfor() {
      this.$axios
        .post("/app/v1/platform/company/reviewDetail", {
          companyid: this.companyId,
          type: this.type
        })
        .then(res => {
          let resp = res.data;
          if (resp.message === "success.") {
            this.baseInfo = resp.data;
            this.imgDatas = this.baseInfo.pictureurls.split(";");
            // 然后根据id获取执照
            let id = resp.data.buslicenseid;
            this.getLogo(id);
          } else {
            this.$message({
              message: resp.message,
              type: "error"
            });
          }
        });
    },
    getLogo(id) {
      if (!id) return;
      let params = {
        accessoryid: id,
        updownmark: "1"
      };
      this.$axios.post("/system/v1/common/upAndDown", params).then(res => {
        if (res.data.message === "success.") {
          this.logoUrl = res.data.data.filecontent;
        }
      });
    },
    resultChange(r) {
      if (r === "1") this.remark = "";
    },
    cancel() {
      this.$emit("cancelCheck", false);
    },
    isShowImg() {
      this.dialogVisible = true;
    },
    //查看企业风采。优质企业 type =1 风采 type =2 优质
    currentImgShow(type, url) {
      if (type == 1) {
        this.currentTitle = "企业风采"
        this.currentUrl = url;
      } else if (type == 2) {
        this.currentTitle = "优质认证"
        this.currentUrl = url;
      } else if (type == 3) {
        this.currentTitle = "知名认证"
        this.currentUrl = url;
      }

      this.imgDialogVisible = true;
    },
    submit() {
      if (this.result === "2" && !this.remark.trim()) {
        this.$message({
          message: "驳回原因不能为空",
          type: "warning"
        });
        return;
      }
      this.$confirm("是否确定提交？", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
        .then(() => {
          let params = {
            companyid: this.companyId,
            type: this.type,
            result: this.result,
            remark: this.remark
          };
          this.$axios
            .post("/app/v1/platform/company/reviewResult", params)
            .then(res => {
              if (res.data.message === "success.") {
                if (this.result === "1") {
                  this.$message({
                    message: "审核成功!",
                    type: "success"
                  });
                } else {
                  this.$message({
                    message: "申请已驳回!",
                    type: "warning"
                  });
                }
                this.cancel();
              } else {
                this.$message({
                  message: res.data.message,
                  type: "error"
                });
                this.cancel();
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    }
  }
};